package com.itbaizhan.idempotency;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;

/**
 * @author spf
 * @date 2024/4/27
 * @time 11:48
 */
@Configuration
public class MyMvcConfig implements WebMvcConfigurer {

    @Autowired
    private ApiIdempotentInterceptor apiIdempotentInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        ArrayList<String> list = new ArrayList<>();
        list.add("/user/index");
        list.add("/user/toAdd");
        list.add("/user/getUserById");
        list.add("/user/update");
        registry.addInterceptor(apiIdempotentInterceptor).excludePathPatterns(list);
    }
}
